package oa.dao.impl;

import java.util.Collection;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import oa.dao.TopicDao;
import oa.dao.base.impl.BaseDaoImpl;
import oa.domain.forum.Forum;
import oa.domain.forum.Topic;

@Repository("topicDao")
public class TopicDaoImpl extends BaseDaoImpl<Topic> implements TopicDao {

	@Resource(name="hibernateTemplate")	
	public HibernateTemplate hibernateTemplate;
	
	@Override
	public Collection<Topic> findTopicByForum(Forum forum) {
		// TODO Auto-generated method stub
		
		return (Collection<Topic>) this.hibernateTemplate.find("from Topic t where t.forum=? order by (case t.type when 2 then 2 else 1 end) desc,t.postTime desc)", forum);
	}

}
